package code.rocky.chapter05;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Suggest71 {
    public static void main(String[] args) {
        demo01();
        demo02();
        demo03();
    }

    private static void demo01() {
        List<Integer> initData = Collections.nCopies(100, 0);
        List<Integer> list = new ArrayList<>(initData);
        for (int i = 0; i < list.size(); i++) {
            if (i >= 20 && i < 30) {
                list.remove(i);
            }
        }
    }

    private static void demo02() {
        List<Integer> initData = Collections.nCopies(100, 0);
        List<Integer> list = new ArrayList<>(initData);
        for (int i = 20; i < 30; i++) {
            if (i < list.size()) {
                list.remove(i);
            }
        }
    }

    private static void demo03() {
        List<Integer> initData = Collections.nCopies(100, 0);
        List<Integer> list = new ArrayList<>(initData);
        list.subList(20, 30).clear();
    }
}
